//
//  main.m
//  oc_10
//
//  Created by 楼楚 on 15/9/11.
//  Copyright (c) 2015年 Chu Lou. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
       NSString *str = @"hello world";
        
        NSMutableString *mStr1 = [[NSMutableString alloc]initWithString:str];
        NSMutableString *mStr2 = [NSMutableString stringWithString:str];
        NSMutableString *mStr3 = [[NSMutableString alloc]initWithUTF8String:"hello world"];
        NSMutableString *mStr4 = [NSMutableString stringWithUTF8String:"hello world"];
        NSMutableString *mStr5 = [[NSMutableString alloc]initWithFormat:@"hello %@",@"world"];
        NSMutableString *mStr6 = [NSMutableString stringWithFormat:@"hello %@",@"world"];
        
//          NSLog(@"%@",mStr1);
////        NSLog(@"%@",mStr2);
////        NSLog(@"%@",mStr3);
////        NSLog(@"%@",mStr4);
////        NSLog(@"%@",mStr5);
////        NSLog(@"%@",mStr6);
        [mStr1 setString:@"hello oc"];
        NSLog(@"%@",mStr1);
        //1.增 2. 删 3. 查 4.改
        [mStr1 appendString:@"xxxx"];
        NSLog(@"%@",mStr1);
        [mStr1 appendFormat:@"%@,%c",str,'f'];// 格式化追加字符串
        NSLog(@"%@",mStr1);
        
        
        [mStr1 insertString:@"sssss" atIndex:5];//指定位置插入制定字符
        NSLog(@"%@",mStr1);
        
        [mStr1 deleteCharactersInRange:NSMakeRange(7, 4)];// 删除制定范围内的字符
        NSLog(@"%@",mStr1);
      
       NSRange range = [mStr1 rangeOfString:str];//查询str在mStr1中所在位置
        
        [mStr1 replaceCharactersInRange:(NSRange){6,5} withString:@"00000"];
         NSLog(@"%@",mStr1);
    }
    return 0;
}
